import React, {Component} from "react";
class Counter extends Component
{
    constructor(props) {
        super(props);

        this.state = {
            counter: 0
        }
    }

    add(e) {
        this.state.counter ++;
        this.setState({counter: this.state.counter})

    }
    sub(e) {
        this.state.counter --;
        this.setState({counter: this.state.counter })
    }
    render() {
        const counter = this.state.counter;
        return (
            <div>
                <p >
                    counter {counter}  . click to increase.
                </p>
                <button onClick={this.add.bind(this)}> + </button>
                <button onClick={this.sub.bind(this)}> - </button>
            </div>

        );
    }
}

export default Counter;
